package com.jay.net.clazz;

import java.io.IOException;
import java.net.InetAddress;

public class InetAddressCls {
	public static void main(String[] args) throws IOException {
		InetAddress address = InetAddress.getByName("www.baidu.com");
		System.out.println(address);
		System.out.println("-----");

		InetAddress[] addresses = InetAddress.getAllByName("www.google.com");
		for (InetAddress addr : addresses) {
			System.out.println(addr);
		}

		System.out.println("-----");
		InetAddress local = InetAddress.getLocalHost();
		System.out.println(local);
		System.out.println(local.getCanonicalHostName());
		System.out.println(local.getHostAddress());
		System.out.println(local.getHostName());
		System.out.println(local.getAddress());
		System.out.println(local.isAnyLocalAddress());
		System.out.println(local.isLinkLocalAddress());
		System.out.println(local.isLoopbackAddress());
		System.out.println(local.isMCGlobal());
		System.out.println(local.isMCLinkLocal());
		System.out.println(local.isMCNodeLocal());
		System.out.println(local.isMCOrgLocal());
		System.out.println(local.isMCSiteLocal());
		System.out.println(local.isMulticastAddress());
		System.out.println(local.isSiteLocalAddress());
		System.out.println(local.isReachable(100));
		

		InetAddress loopBack = InetAddress.getLoopbackAddress();
		System.out.println(loopBack);
		System.out.println(loopBack.isLoopbackAddress());
		
		InetAddress any = InetAddress.getByName("0.0.0.0");
		System.out.println(any);
		System.out.println(any.isAnyLocalAddress());

	}
}
